class CreateBookings < ActiveRecord::Migration
  def self.up
    create_table :bookings do |t|
      t.date :booking_date
      t.integer :cust_id, :null => false
      t.integer :camp_id, :null => false
      t.date :arrival_date
      t.decimal :nights
      t.decimal :adults
      t.decimal :children
      t.float :total

      t.timestamps
    end
    execute "ALTER TABLE bookings ADD CONSTRAINT bookings_cust_FK
             FOREIGN KEY (cust_id) REFERENCES customers(id)"
    execute "ALTER TABLE bookings ADD CONSTRAINT bookings_camps_FK
             FOREIGN KEY (camp_id) REFERENCES campsites(id)"
  end

  def self.down
    drop_table :bookings
  end
end
